package com.android.job.ui.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.android.job.ui.R;

/**
 * 公告数据适配器
 * @author Administrator
 *
 */
public class RoomAdapter extends BaseAdapter
{
	private Context context;
	private ArrayList<String> list;
	private ViewHolder holder;
	int pos;

	public RoomAdapter(Context con, ArrayList<String> room)
	{
		this.context = con;
		this.list = room;
	}

	@Override
	public int getCount()
	{
		return list.size();
	}

	@Override
	public Object getItem(int position)
	{
		return position;
	}

	@Override
	public long getItemId(int position)
	{
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		pos =position;
		if (null == convertView)
		{
			holder = new ViewHolder();
//			convertView = LayoutInflater.from(context).inflate(
//					R.layout.booking, null);
//			holder.content = (TextView) convertView
//					.findViewById(R.id.meetingroom);
//			holder.booking = (Button) convertView
//					.findViewById(R.id.bookingBtn);
//			holder.booking.setId(position);
			convertView.setTag(holder);
		}
		else
		{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.content.setText(list.get(position));
		holder.booking.setText("预 订");
		holder.booking.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
//				Intent intent = new Intent(context,BookingActivity.class);
//				Bundle bundle = new Bundle();
//				bundle.putSerializable("meetingroom", list.get(pos));
//				intent.putExtras(bundle);
//				context.startActivity(intent);
			}
		});
		return convertView;
	}

	private class ViewHolder
	{
		/**
		 * 公告内容
		 */
		private TextView content;

		/**
		 * 公告时间
		 */
		private Button booking;

	}

}
